package com.example.service_consumer.fallback;

import com.example.service_consumer.remoteService.ProviderService;
import feign.hystrix.FallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
//import org.springframework.cloud.openfeign.FallbackFactory;

import org.springframework.stereotype.Component;

@Component
public class FallbackRemoteCall implements FallbackFactory<ProviderService> {
    private static final Logger log = LoggerFactory.getLogger(FallbackRemoteCall.class);
    @Override
    public ProviderService create(Throwable throwable){
        log.error("用户服务Provider 调用失败:{}",throwable.getMessage());
        return new ProviderService() {
            @Override
            public String hello() {
                return "获取Provider hello 失败:" + throwable.getMessage();
            }

            @Override
            public String requestTimeOut() {
                return "获取Provider timeOut 失败:" + throwable.getMessage();
            }
        };
    }
}
